<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%String path=request.getContextPath();String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";if(session.getAttribute("user")==null){response.sendRedirect(basePath);};%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
	<link rel="stylesheet" type="text/css" href="css/dtree.css"/>
	<link rel="stylesheet" type="text/css" href="css/main.css"/>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="dwr/engine.js"></script>
	<script type="text/javascript" src="dwr/util.js"></script>
	<script type="text/javascript" src="dwr/interface/findUserById.js"></script>
	<script type="text/javascript">
	function showdepartment(){
		var vRValue = window.showModalDialog("page/basic/depTree_1.jsp",null,"dialogWidth=600px;dialogHeight=450px;status=0;scroll=0");
		if(vRValue == undefined){
	  	  	vRValue = '';
	  	}
		var uid = (vRValue=='')?'':vRValue.split(',')[0];
		var uname = (vRValue=='')?'':vRValue.split(',')[1];
		if(uid != undefined && uname != undefined){
			$('input#Departmentsname').val(uid);
			$('input#staff').val(uname);
		}
	}
	function validate(){
		if($('div#usercodeMessage').html()!=""||$('div#usernameMessage').html()!=""){
			return false;
		}else{
			return true;
		}
	}
		$(document).ready(function(){
			$('input#uc').blur(function(){
				findUserById.getUser($('input#uc').val(),function(message){
					if(message!=null){
						$('div#usercodeMessage').html("该账号已注册");
					}else{
						
					}
				});
				if($(this).val().length>11){
					$('div#usercodeMessage').html("账号不能大于11位");
				}else if($(this).val().length==0){
					$('div#usercodeMessage').html("账号不能为空");
				}
			}).focus(function(){
				$('div#usercodeMessage').html("");
			});
			$('input#un').blur(function(){
				if($(this).val().length==0){
					$('div#usernameMessage').html("用户名不能为空");
				}
			}).focus(function(){
				$('div#usernameMessage').html("");
			});
		});	
		function doBack(){
			location.href="findAllUser.action";
		}
	</script>
  </head>
  <body>
<form action="insertUser.action" method="post" onsubmit="return validate();">
<div class="mainContainer">
	<div class="headerTitle"><s:property value="navStr" /></div>
	<div class="dataDivLeftNoTree">

 <table class="formTable" border="0" cellspacing="0" cellpadding="0">
	<tr class="operatorAction">
		<td>
			<!-- 功能性操作 -->
			<!--<input type="button" onclick="location.href='tmplt-list?FN=<s:property value='FN' />'" value="刷新" />
			<input type="button" onclick="location.href='tmplt-add?FN=<s:property value='FN' />&opt=0'" value="新增" />
			<input type="button" onclick="location.href='tmplt-del?FN=<s:property value='FN' />'" value="删除" />
			<input type="button" onclick="location.href='tmplt-export?FN=<s:property value='FN' />'" value="导出" />
			<input type="text" class="qryTxt" /><input type="button" style="margin-left:1px;" value="查询" />
			-->
			<input id="sbm" type="submit" value="提交" />
	        <input type="button" onclick="doBack();" value="返回" />
		</td>
	</tr>
    <tr>
		<td class="formData">
			<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
	          <tr class="dataRow">
	            <td><div  style="display: inline">用户账号：<input id="uc" type="text" name="uc" id="usercode"/></div></td>
	            <td id="usercodetest"><div id="usercodeMessage" style="display:inline;color:red;"></div></td>
	          </tr>
	          <tr class="dataRow">
	            <td><div  style="display: inline">用户名：<input id="un" type="text" name="un" id="username"/></div></td>
	            <td><div id="usernameMessage" style="display:inline;color:red;"></div></td>
	          </tr>
	         <tr class="dataRow">
	            <td>权限模板：<select id="userrole" name="tmpCode">
	            	  <s:iterator var="t" value="sysTemplates">
	            	  	<option value="<s:property value="#t.templateCode"/>"><s:property value="#t.templateName"/></option>
	            	  </s:iterator>
	            </select></td>
	            <td><!-- 部门：<select id="userpepart" name="depid">
	            	  <s:iterator var="d" value="departments">
	            	  	<option value="<s:property value="#d.depid"/>"><s:property value="#d.depname"/></option>
	            	  </s:iterator>
	            </select> --></td>
	          </tr>
	           <tr class="dataRow"><td>持有人：
	            <input type="hidden" id="Departmentsname" name="depid" />
	            <input type="text" id="staff" name="stid" value="" readonly="readonly"/><img src="images/showDep.gif" onclick="showdepartment()" style="cursor: pointer;" alt="选择上级部门" title="员工" /></td>
	            <td>
	            账号状态：<select id="userstatus" name="sttus">
	            	  <option value="A">在用</option>
	            	  <option value="D">停用</option>
	            </select>
	            </td>
	          </tr>
			</table>
		</td>
	</tr>
</table>
</div>
</div>
</form>
</body>
</html>
